import React, { Component } from 'react'

export default class Count extends Component {

  state ={carName:'奔驰'}

  increment = ()=>{
    const {value} = this.selectNumber
    this.props.jia(value*1)
  }
  decrement = ()=>{
    const {value} = this.selectNumber
    this.props.jian(value*1)
  }
  incrementOdd = ()=>{
    const {value} = this.selectNumber
    if (this.props.count%2) {
      this.props.jia(value*1)
    }
  }
  incrementWait = ()=>{
    const {value} = this.selectNumber
    this.props.jiaAsync(value*1,500)
  }


  render() {
    console.log(this.props);
    return (
      <div>
        <h1>当前求和为:{this.props.count}</h1>
        <select ref={(c)=>{this.selectNumber = c}}>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
        </select>
        <button onClick={this.increment}>加</button>
        <button onClick={this.decrement}>减</button>
        <button onClick={this.incrementOdd}>奇数加</button>
        <button onClick={this.incrementWait}>等一等加</button>
      </div>
    )
  }
}
